// 计算高差角
export function calcAngle(h: number, l: number) {
  const angle = Math.atan(h / l)
  return angle
}

// 计算水平张力Hi
export function calcHi(w: number, n: number, l: number, N: number, y: number, angle: number) {
  const b = 2 * (N - y) * Math.cos(angle) + 2 * n * Math.sin(angle)
  const Hi = (w * n * (l - n)) / b
  return Hi
}

// 计算最大弧垂
export function calcF(l: number, w: number, Hi: number, angle: number) {
  const f = (l ** 2 * w) / 8 / Hi / Math.cos(angle)
  return f
}

// 计算平视弧垂FB
export function calcFB(f: number, h: number) {
  const FB = f * (1 + h / 4 / f) ** 2
  return FB
}

// 通过FB计算TB
export function calcTBFromFB(Hi: number, w: number, FB: number, angle: number) {
  const TB = Hi + (w * FB) / Math.cos(angle)
  return TB
}

// 通过TB计算TA
export function calcTAFromTB(TB: number, w: number, h: number, angle: number) {
  const TA = TB - (w * h) / Math.cos(angle)
  return TA
}

// 通过TA计算TB
export function calcTBFromTA(TA: number, w: number, m: number, h: number, angle: number) {
  const TB = m * TA + (m * w * h) / Math.cos(angle)
  return TB
}
